
#ifndef __H_PROCESS_H__
#define __H_PROCESS_H__

#include "linux_def.h"
#include "core.h"

typedef void (*spawn_proc_pt)(cycle_t *cycle, void *data);

typedef struct{
	pid_t	pid;
	int	status;
	int	channel[2];
	spawn_proc_pt	proc;
	void	*data;
	char	*name;
	
	unsigned	respawn:1;
	unsigned	just_spawn:1;
	unsigned	detached:1;
	unsigned	exiting:1;
	unsigned	exited:1;
}process_t;

#define MAX_PROCESSES	1024

#define	PROCESS_NORESPAWN	-1
#define	PROCESS_JUST_SPAWN	-2
#define	PROCESS_RESPAWN		-3
#define	PROCESS_JUST_RESPAWN	-4
#define	PROCESS_DETACHED	-5

pid_t	spawn_process(cycle_t *cycle, spawn_proc_pt proc, void *data, char *name, int respawn);
int	init_signals();

extern	pid_t	g_pid;
extern	int	g_channel;
extern	int	process_slot;
extern	int	process_last;
extern  process_t processes[MAX_PROCESSES];

#endif
